#ifndef SC_ADB_PARSER_H
#define SC_ADB_PARSER_H

#include "common.h"

#include <stddef.h>

#include "adb_device.h"

/**
 * Parse the available devices from the output of `adb devices`.
 * The parameter must be a NUL-terminated string.
 * Warning: this function modifies the buffer for optimization purposes.
 * @param str 设备信息字符串 The parameter must be a NUL-terminated string. 参数需要是 \0 结尾的字符串
 * @param out_vec android设备数组，解析的结果要写入此处
 * @return 如果找到命令行的头刚返回true，否则返回false
 */
bool
sc_adb_parse_devices(char *str, struct sc_vec_adb_devices *out_vec);

/**
 * Parse the ip from the output of `adb shell ip route`
 *
 * @param str The parameter must be a NUL-terminated string.
 *
 * Warning: this function modifies the buffer for optimization purposes.
 * @return wifi下的ip地址，如果有多个，只返回第一行的有效IP地址
 */
char *
sc_adb_parse_device_ip(char *str);

#ifndef NDEBUG
/*
char *
debug_sc_adb_parse_device_ip_from_line(char *line)
{
    return sc_adb_parse_device_ip_from_line(line);
}
*/
#endif
#endif
